﻿
@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <title>锦福缘母婴湾系统平台</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/assets/component/pear/css/pear.css" />
    <link rel="stylesheet" href="/assets/admin/css/admin.css" />
    <link rel="stylesheet" href="/assets/admin/css/admin.dark.css" />
    <link rel="stylesheet" href="/assets/admin/css/variables.css" />
    <link rel="stylesheet" href="/assets/admin/css/reset.css" />

</head>
<!-- 结 构 代 码 -->
<body class="layui-layout-body pear-admin">
    <!-- 布 局 框 架 -->
    <div class="layui-layout layui-layout-admin">
        <!-- 顶 部 样 式 -->
        <div class="layui-header">
            <!-- 菜 单 顶 部 -->
            <div class="layui-logo">
                <!-- 图 标 -->
                <img class="logo">
                <!-- 标 题 -->
                <span class="title"></span>
            </div>
            <!-- 顶 部 左 侧 功 能 -->
            <ul class="layui-nav layui-layout-left">
                <li class="collapse layui-nav-item"><a href="#" class="layui-icon layui-icon-shrink-right"></a></li>
                <li class="refresh layui-nav-item"><a href="#" class="layui-icon layui-icon-refresh-1" loading=600></a></li>
                <li id="loginAcccount" class="layui-nav-item" style="color:white"></li>
            </ul>
            <!-- 多 系 统 菜 单 -->
            <div id="control" class="layui-layout-control"></div>
            <!-- 顶 部 右 侧 菜 单 -->
            <ul class="layui-nav layui-layout-right">
                <li class="layui-nav-item layui-hide-xs"><a href="#" class="menuSearch layui-icon layui-icon-search"></a></li>
                <li class="layui-nav-item layui-hide-xs message"><span class="message-count" id="count">0</span></li>
                <li class="layui-nav-item layui-hide-xs"><a href="#" class="fullScreen layui-icon layui-icon-screen-full"></a></li>
                <li class="layui-nav-item user">
                    <!-- 头 像 -->
                    <a class="layui-icon layui-icon-username" href="javascript:;"></a>
                    <!-- 功 能 菜 单 -->
                    <dl class="layui-nav-child">
                        <dd><a user-menu-url="view/profile/index.html" user-menu-id="5555" user-menu-title="基本资料">基本资料</a></dd>
                        <dd><a href="javascript:void(0);" class="logout">注销登录</a></dd>
                    </dl>
                </li>
                <!-- 主 题 配 置 -->
                <li class="layui-nav-item setting"><a href="#" class="layui-icon layui-icon-more-vertical"></a></li>
            </ul>
        </div>
        <!-- 侧 边 区 域 -->
        <div class="layui-side layui-bg-black">
            <!-- 菜 单 顶 部 -->
            <div class="layui-logo">
                <!-- 图 标 -->
                <img class="logo">
                <!-- 标 题 -->
                <span class="title"></span>
            </div>
            <!-- 菜 单 内 容 -->
            <div class="layui-side-scroll">
                <div id="side"></div>
            </div>
        </div>
        <!-- 视 图 页 面 -->
        <div class="layui-body">
            <!-- 内 容 页 面 -->
            <div id="content"></div>
        </div>
        <!-- 页脚 -->
        <div class="layui-footer layui-text"></div>
        <!-- 遮 盖 层 -->
        <div class="pear-cover"></div>
        <!-- 加 载 动 画 -->
        <div class="loader-wrapper">
            <!-- 动 画 对 象 -->
            <div class="loader"></div>
        </div>
    </div>
    <!-- 移 动 端 便 捷 操 作 -->
    <div class="pear-collapsed-pe collapse">
        <a href="#" class="layui-icon layui-icon-shrink-right"></a>
    </div>
    <!-- 依 赖 脚 本 -->
    <script src="~/Assets/bootstrap/js/jquery-1.10.2.min.js"></script>
    <link href="~/Assets/component/layui/css/layui.css" rel="stylesheet" />
    <script src="/assets/component/layui/layui.js"></script>
    <script src="/assets/component/pear/pear.js"></script>
    <script src="/Assets/hplus-admin/js/plugins/peity/jquery.peity.min.js"></script>
    <script src="~/Assets/Scripts/jquery.signalR-2.4.3.min.js"></script>
    <!--引用自动生成的SignalR集线器(Hub)脚本.在运行的时候在浏览器的Source下可看到-->
    <script src="/signalr/hubs" type="text/javascript"></script>
    <!-- 框 架 初 始 化 -->
    <script>
        window.onload = function () {
            let userName = '@ViewBag.userName'
            let userNumber = '@ViewBag.userNumber'
            $("#loginAcccount").html(`姓名：${userName}&nbsp&nbsp&nbsp工号：${userNumber}`)
        layui.use(['admin', 'jquery', 'popup'], function () {
            var admin = layui.admin;
            var popup = layui.popup;
            var $ = layui.jquery;
            var chat = $.connection.mailboxChatHub;
            $.post("/Mailbox/Mail", function (resp) {
                $("#count").html(resp.count || 0)
            })
            chat.client.RevMail = function (json) {
                $.post("/Mailbox/Mail", function (resp) {
                    $("#count").html(resp.count || 0)
                })
            }
            $.connection.hub.start().done(function () {
                console.log("SignalR 连接已建立");
                chat.server.sendAllMail()
            });

            // yml | json | api
            admin.setConfigurationPath("/Assets/config/pear.config.json");
            $('.message').on('click', function () {
                var inboxPageUrl = '/Mailbox/Mailbox';
                layer.open({
                    type: 2,
                    title: '站内信',
                    area: ['80%', '80%'],
                    content: inboxPageUrl
                });
            });
            // 渲染
            admin.render();

            // 注销
            admin.logout(function () {

                popup.success("注销成功", function () {
                    location.href = "/home/login";
                })

                // 清空 tabs 缓存
                return new Promise((resolve) => {
                    resolve(true)
                });
            });
        })
        }
    </script>
    <style>
        .message {
            position: relative; /* 相对定位，为内部绝对定位元素提供定位基准 */
        }

        .message-count {
            position: absolute;
            top: 10px;
            right: 0;
            display: inline-block;
            width: 18px;
            height: 18px;
            line-height: 18px;
            text-align: center;
            border-radius: 50%;
            background-color: red; /* 根据需求调整颜色，比如有新消息时显示红色等 */
            color: white;
            font-size: 12px;
        }
    </style>
</body>
</html>
